/**
 * 
 */
package edu.umd.clip.lm.model.decoding;

import java.util.*;

import edu.berkeley.nlp.util.Pair;
import edu.umd.clip.lm.util.BinaryPrefix;
import edu.umd.clip.lm.model.*;
import edu.umd.clip.lm.factors.*;

/**
 * @author Denis Filimonov <den@cs.umd.edu>
 *
 */
public abstract class Tagger {
	final int beamSize;
	final Decoder decoder;
	final BinaryPrefix tags[];
	final byte tagFactorIdx;
	
	protected long taggingTime = 0;
	protected long updatePathsTime = 0;
	protected long makingTaggerSliceTime = 0;

	public Tagger(Decoder decoder, int beamSize, String tagFactor) {
		this.decoder = decoder; 
		this.beamSize = beamSize;
		Experiment exp = Experiment.getInstance();
		this.tagFactorIdx = exp.getTupleDescription().getFactorIndex(tagFactor);
		this.tags = exp.getTags(tagFactorIdx);
	}

	public abstract Pair<SortedSet<? extends TaggedPath>, Double> evaluateSentence(Collection<FactorTuple> sentence);
	
	public Pair<SortedSet<? extends TaggedPath>, Double> evaluateSentence(long[] sentence) {
		ArrayList<FactorTuple> tuples = new ArrayList<FactorTuple>(sentence.length);
		for(long tuple : sentence) {
			tuples.add(new FactorTuple(tuple));
		}
		return evaluateSentence(tuples);
	}
}
